package flp.problem;

public class RiverFacility
{
	int towVolumenLimit;
	int bargesRequiredToNumber[];   //ilosc barek płynacych z tego duzego portu do innych
	double bargesFromRequiringCleaningPrecentage; //procent barek wymagajacych mycia
	
        @Override
        public String toString()
        {
            String rep = String.format("\tlimit: %s (%s)\n\t", towVolumenLimit,
                    bargesFromRequiringCleaningPrecentage);
            for (int brtn : bargesRequiredToNumber)
            {
                rep += String.format(" %s", brtn);
            }
            return rep + "\n";
        }
        
	public RiverFacility(int towVolumenLimit, int[] bargesRequiredToNumber,
			double bargesFromRequiringCleaningPrecentage)
	{
		this.towVolumenLimit = towVolumenLimit;
		this.bargesRequiredToNumber = bargesRequiredToNumber;
		this.bargesFromRequiringCleaningPrecentage = bargesFromRequiringCleaningPrecentage;
	}

        /**
         * Zwraca ilosc barek plynacych do zadanego riverFacility mytych lub nie.
         * 
         * @param riverFacilityID Dokad plynace barki nas interesuja?
         * @param toClean Czy do mycia?
         * @return Ilosc barek.
         */
	public int getBargesRequiredToNumber(int riverFacilityID, boolean toClean)
	{
		return
		toClean
		 ? (int)Math.floor(bargesRequiredToNumber[riverFacilityID] * bargesFromRequiringCleaningPrecentage)    
		 : (int)Math.floor(bargesRequiredToNumber[riverFacilityID] * (1.0 - bargesFromRequiringCleaningPrecentage)) 
		;
	}
	
        /**
         * Zwraca sumaryczna ilosc barek.
         * 
         * @param riverFacilityID Dokad płynace barki nas interesuja?
         * @return Sumarczyna ilosc barek.
         */
	public int getBargesRequiredToNumber(int riverFacilityID)
	{
		return getBargesRequiredToNumber(riverFacilityID, true) + getBargesRequiredToNumber(riverFacilityID, false); 
	}
	
}
